<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>快招</title>
		<meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1,user-scalable=no">
		<meta name="apple-mobile-web-app-capable" content="yes">
		<meta name="apple-mobile-web-app-status-bar-style" content="black">
		<link rel="stylesheet" href="/public/weixin/css/mui.min.css">
		<link rel="stylesheet" href="/public/weixin/css/iconfont/iconfont.css" />
		<link rel="stylesheet" href="/public/weixin/css/css/index.css">
	</head>
<body>
	<header class="mui-bar mui-bar-nav">
		<a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
		<h1 class="mui-title">借支申请</h1>
		<a id="borrowHistory" class=" mui-icon mui-icon mui-icon mui-icon-more mui-pull-right"></a>
	</header>
	<div class="mui-content">
		<p class="own_shenqing_p">
			请如实填写表单信息,信息真实性将直接影响<br/>
			&nbsp;&nbsp;&nbsp;后期的审核与借支业务
		</p>
		<div class="own_shenqing">
			<div class="own_shenqing_list">
				<div class="own_shenqing_item">姓名</div>
				<div class="own_shenqing_item">
					<span><?php echo ($personInfo["name"]); ?></span>
				</div>
			</div>
			<div class="own_shenqing_list">
				<div class="own_shenqing_item">身份证　</div>
				<div class="own_shenqing_item">
					<span><?php echo ($personInfo["card"]); ?></span>
				</div>
			</div>
			<div class="own_shenqing_list">
				<div class="own_shenqing_item">手机号　</div>
				<div class="own_shenqing_item">
					<span><?php echo ($personInfo["mobile"]); ?></span>
				</div>
			</div>
			<div class="own_shenqing_list">
					<div class="own_shenqing_item">借支企业</div>
					<div class="own_shenqing_item">
						    <select id = "comID" name = "comID" disabled="disabled">
						    	<?php if(is_array($personInfo["comlist"])): foreach($personInfo["comlist"] as $key=>$item): ?><option value="<?php echo ($item["com_id"]); ?>">  <?php echo ($item["com_name"]); ?></option><?php endforeach; endif; ?>
						    </select>
					</div>
				</div>
		</div>
		
		<div class="own_shenqing">
				<div class="own_shenqing_list">
					<div class="own_shenqing_item">借支金额</div>
					<div class="own_shenqing_item">
						<input type="tel" id="num" name="num" placeholder="今日最高可申请 <?php echo ($personInfo["maxValue"]); ?>元"/>
					</div>
				</div>

				<div class="own_shenqing_list">
					<div class="own_shenqing_item" style="margin-top: 2%;">提款方式</div>
					 <?php echo ($type); ?>
				</div>
				
			<div class="own_shenqing_list" id="bankDIV" >
				<div class="own_shenqing_item">
					到账银行
				</div>
				<div class="own_shenqing_item" >
				    <input type="hidden" id="bank_invite_id" value="<?php echo ($bank_invite_id); ?>">
				    <span id="bank_span"> <?php echo C('BANK_TYPE')[$bank_id]['dict_text'];?> <?php echo ($bank_number); ?></span>
				</div>
			</div>
				
				<div class="own_shenqing_item"  style="margin-right: 4%;">
					    <textarea id="reason" name="reason" rows="3" cols="2" placeholder="请简单描述借支理由..."></textarea>
				</div>
		</div>
		
		<div class="own_shenqing_button">
			<div class="mui-content-padded">
				<button type="button" id="joinBtn" class="mui-btn mui-btn-primary mui-btn-block">
					提交申请
				</button>
			</div>
		</div>
	</div>
</body>
<script src="/public/js/mui/js/mui.js"></script>
<script src="/public/js/jquery.js"></script>
<script type="text/javascript">
$(function() {
	var $bank_invite_id = $("#bank_invite_id").val();
	 if($bank_invite_id != '' ){
		 $("input[name='type']:first").attr("checked",true);
	 }else{
		 $("#bankDIV").hide();
	 }
	$("input[name='type']:first").click(  /**点击【银行卡】选项**/
	       function(event){
	    	    $("#bankDIV").show();
	    	    var $bank_invite_id = $("#bank_invite_id").val();
	    	    if($bank_invite_id != '')	return;
	    	    window.location.href="<?php echo U('User/bank_list_select','user_type=2');?>";
	       }
	);
	$("input[name='type']:last").click(  /**点击【现金】选项**/
		       function(event){
		    	    $("#bankDIV").hide();
		       }
		);
	$("#bank_span").click(function(){
		window.location.href="<?php echo U('User/bank_list_select','user_type=2');?>";
	});
	
	$("#joinBtn").click(function(){
		var $reason = $("#reason").val();
		var $comID = $("#comID").val();
		var $num = $("#num").val();
		var $bank_id = $("#bank_invite_id").val();
		var $type = $("input[name='type']:checked").val();
		if($num == ''){
			mui.toast("请输入借支金额");
			return;
		}
		if($comID == ''){
			mui.toast("请选择借支企业");
			return;
		}
		if(typeof($type)=="undefined"){
			mui.toast("请选择收款方式");
			return;
		}else if( 1 == $type &&  $bank_id==''){
			mui.toast("请选择到账银行或选择现金");
			return;
		}
		mui.ajax("<?php echo U('User/borrowRequest');?>",{
			data : {
				"reason" : $reason,
				"comID" : $comID,
				"num" : $num,
				"type" : $type,
				"bank_id":$bank_id
			},
			dataType : 'json',//服务器返回json格式数据
			type : 'GET',//HTTP请求类型
			timeout : 10000,//超时时间设置为10秒；
			success : function(data){
				if (data['state'] == 1) {
					mui.alert("申请成功<br/>快招将在两个工作日内处理");
					window.location.href="<?php echo U('User/userCenter');?>";
				}else{
					mui.alert(data['msg']);
				}
			},
			error:function(xhr,type,errorThrown){
				//异常处理；
				mui.alert("申请失败请重试！");
			}
		});
	});
	$("#borrowHistory").on("tap",borrowHistory);
	/**借支历史 borrowHistory***/
	function borrowHistory(){
		window.location.href="<?php echo U('User/borrowList');?>";
	}
	
});
</script>
</html>